package cn.xyf.mzmy.common.pojo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Schema(description="分页结果")
@Data
public class PageResult<T> {

    private List<T> pageData;

    private Long total;

    /**
     * mpPage转成Page
     *
     * @param mpPage mp的分页结果
     * @param <T>    类型
     * @return page
     */
    public static <T> PageResult<T> convert(IPage<T> mpPage) {
        PageResult<T> page = new PageResult<>();
        page.setPageData(mpPage.getRecords());
        page.setTotal(mpPage.getTotal());
        return page;
    }
}
